package com.zijie.shopgoodsapi.goods.mapper;

import  com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.zijie.goods.model.Goods;
import com.zijie.goods.model.search.GoodSearchBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface GoodMapper extends BaseMapper<Goods> {
     default Page<Goods> findAll(Page<Goods> page, GoodSearchBean gsb){
//         System.out.println(page.getSize()+" "+page.getPages());
         LambdaQueryWrapper<Goods> query = Wrappers.lambdaQuery(gsb);
         return selectPage(page, query);
     }
     @Update("update good set is_hot = #{newStatus} where id = #{id}")
     boolean updateHotStatus(Integer id, Integer newStatus);
    @Update("update good set is_take_down = #{downStatus} where id = #{id}")
    boolean updatePublicStatus(Integer id, Integer downStatus);
}
